package one;

import java.util.*;

public class demo1 {


    public static void main(String[] args) {

        Bookstore bookstore;

        int bookNum = 1000;
        int userNum = 800;
        int userBookNum = 900;
        int userBookRatingsNum = 800;

        Book[] bookArr = new Book[bookNum];
        for (int i = 0; i < bookNum; i++) {
            bookArr[i] = new Book(i, "bookName"+i, "author"+i);
        }

        User[] userArr = new User[userNum];
        Random random = new Random();
        for (int i = 0; i < userNum; i++) {
            userArr[i] = new User(i,"name"+i);
            List<Book> objects = new ArrayList<>();
            for (int j = 0; j < userBookNum; j++) {
                //System.out.println("book"+random.nextInt(bookNum));
                objects.add(bookArr[random.nextInt(bookNum)]);
            }
            userArr[i].setPurchaseHistory(objects);
            Map<Book, Integer> map = new HashMap<>();
            for (int j = 0; j < userBookRatingsNum; j++) {
                //System.out.println("ratings"+random.nextInt(6));
                map.put(bookArr[random.nextInt(bookNum)], random.nextInt(6));
            }
            userArr[i].setRatings(map);
        }

        ArrayList<Book> objectBook = new ArrayList<>();
        ArrayList<User> objectsUser = new ArrayList<>();
        Collections.addAll(objectBook,bookArr);
        Collections.addAll(objectsUser,userArr);
        bookstore = new Bookstore(objectBook,objectsUser);

        List<Book> recommendedBooks1 = bookstore.recommendByPurchaseHistory(userArr[0]);
        System.out.println("recommendByPurchaseHistory");
        for (Book recommendedBook : recommendedBooks1) {
            System.out.println(recommendedBook.toString());
        }

        List<Book> recommendedBooks2 = bookstore.recommendByRatings(userArr[0]);
        System.out.println("recommendByRatings");
        for (Book recommendedBook : recommendedBooks2) {
            System.out.println(recommendedBook.toString());
        }
    }

}
